package com.yyx.app1.ui;

import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yyx.app1.DiagnosticTools_function.UI.DiagnosticTools_Activity_;
import com.yyx.app1.MedicationAssistant_function.UI.MedicationAssistant_Activity_;
import com.yyx.app1.MyApp;
import com.yyx.app1.My_function.UI.My_Acitivity_;
import com.yyx.app1.Question_function.UI.Question_Acitivity_;
import com.yyx.app1.R;
import com.yyx.app1.incompatibility_function.UI.Incompatibility_Activity_;

import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.ViewById;

/**
 * Created by yuexing on 2015/9/6.
 */
@EFragment(R.layout.fragment_menu_bottom)
public class BottomMenu_Fragment extends Fragment {
    private int location=99;

    @ViewById
    LinearLayout menu_bottom_first_button,menu_bottom_second_button,menu_bottom_three_button,menu_bottom_fourth_button;

    @ViewById
    TextView menu_bottom_first_button_text,menu_bottom_second_button_text,menu_bottom_three_button_text,menu_bottom_fourth_button_text;

    @ViewById
    ImageView menu_bottom_fifth_button,menu_bottom_first_button_ico,menu_bottom_second_button_ico,menu_bottom_three_button_ico,menu_bottom_fourth_button_ico;

    @Click
    public void menu_bottom_first_button()
    {
        Activity activity = getActivity();
        activity.startActivity(new Intent(activity.getBaseContext(),MedicationAssistant_Activity_.class));
    }

    @Click
    public void menu_bottom_second_button()
    {
        Activity activity = getActivity();
        activity.startActivity(new Intent(activity.getBaseContext(),Incompatibility_Activity_.class));
    }

    @Click
    public void menu_bottom_three_button()
    {
        Activity activity = getActivity();
        activity.startActivity(new Intent(activity.getBaseContext(),DiagnosticTools_Activity_.class));
    }

    @Click
    public void menu_bottom_fourth_button()
    {
        Activity activity = getActivity();
        activity.startActivity(new Intent(activity.getBaseContext(),Question_Acitivity_.class));
    }

    @Click
    public void menu_bottom_fifth_button()
    {
        Activity activity = getActivity();
        activity.startActivity(new Intent(activity.getBaseContext(), My_Acitivity_.class));
    }

    public void setShow(String activityName) {
        switch (location)
        {
            case 1:
                setmenu_bottom_first_button(false);
                break;
            case 2:
                setmenu_bottom_second_button(false);
                break;
            case 3:
                setmenu_bottom_three_button(false);
                break;
            case 4:
                setmenu_bottom_fourth_button(false);
                break;
        }
        switch (activityName)
        {
            case "用药助手":
                location = 1;
                setmenu_bottom_first_button(true);
                break;
            case "配伍禁忌":
                location = 2;
                setmenu_bottom_second_button(true);
                break;
            case "诊疗工具":
                location = 3;
                setmenu_bottom_three_button(true);
                break;
            case "问诊":
                location = 4;
                setmenu_bottom_fourth_button(true);
                break;
            case "首页":
                location = 99;
                break;
        }
    }

    public void setmenu_bottom_first_button(boolean b) {
        if (b)
        {
            menu_bottom_first_button_text.setTextColor(getResources().getColor(R.color.app_color));
            menu_bottom_first_button_ico.setImageBitmap(((MyApp) getActivity().getApplication()).getBaseDataManager().getResDrawable(
                    R.drawable.fragmentmedication2, menu_bottom_first_button_ico.getWidth(), menu_bottom_first_button_ico.getHeight()));
        }
        else
        {
            menu_bottom_first_button_text.setTextColor(getResources().getColor(R.color.gray_unselcet_font));
            menu_bottom_first_button_ico.setImageBitmap(((MyApp) getActivity().getApplication()).getBaseDataManager().getResDrawable(
                    R.drawable.fragmentmedication, menu_bottom_first_button_ico.getWidth(), menu_bottom_first_button_ico.getHeight()));
        }
    }

    public void setmenu_bottom_second_button(boolean b ) {
        if (b)
        {
            menu_bottom_second_button_text.setTextColor(getResources().getColor(R.color.app_color));
            menu_bottom_second_button_ico.setImageBitmap(((MyApp) getActivity().getApplication()).getBaseDataManager().getResDrawable(
                    R.drawable.fragmentincompatibility2, menu_bottom_second_button_ico.getWidth(), menu_bottom_second_button_ico.getHeight()));
        }
        else
        {
            menu_bottom_second_button_text.setTextColor(getResources().getColor(R.color.gray_unselcet_font));
            menu_bottom_second_button_ico.setImageBitmap(((MyApp) getActivity().getApplication()).getBaseDataManager().getResDrawable(
                    R.drawable.fragmentincompatibility, menu_bottom_second_button_ico.getWidth(), menu_bottom_second_button_ico.getHeight()));
        }
    }

    public void setmenu_bottom_three_button(boolean b) {
        if (b)
        {
            menu_bottom_three_button_text.setTextColor(getResources().getColor(R.color.app_color));
            menu_bottom_three_button_ico.setImageBitmap(((MyApp) getActivity().getApplication()).getBaseDataManager().getResDrawable(
                    R.drawable.fragmenttool2, menu_bottom_three_button_ico.getWidth(), menu_bottom_three_button_ico.getHeight()));
        }
        else
        {
            menu_bottom_three_button_text.setTextColor(getResources().getColor(R.color.gray_unselcet_font));
            menu_bottom_three_button_ico.setImageBitmap(((MyApp) getActivity().getApplication()).getBaseDataManager().getResDrawable(
                    R.drawable.fragmenttool, menu_bottom_three_button_ico.getWidth(), menu_bottom_three_button_ico.getHeight()));
        }
    }

    public void setmenu_bottom_fourth_button(boolean b) {
        if (b)
        {
            menu_bottom_fourth_button_text.setTextColor(getResources().getColor(R.color.app_color));
            menu_bottom_fourth_button_ico.setImageBitmap(((MyApp) getActivity().getApplication()).getBaseDataManager().getResDrawable(
                    R.drawable.fragmentwenwen2, menu_bottom_fourth_button_ico.getWidth(), menu_bottom_fourth_button_ico.getHeight()));
        }
        else
        {
            menu_bottom_fourth_button_text.setTextColor(getResources().getColor(R.color.gray_unselcet_font));
            menu_bottom_fourth_button_ico.setImageBitmap(((MyApp) getActivity().getApplication()).getBaseDataManager().getResDrawable(
                    R.drawable.fragmentwenwen, menu_bottom_fourth_button_ico.getWidth(), menu_bottom_fourth_button_ico.getHeight()));
        }
    }
}
